---
title: Migrating to 1.3
description: Migrate to Apollo Android 1.3
---

Apollo Android version 1.3.0 introduces some fixes and improvements that are incompatible with 1.2.x. Updating should be transparent for
simple use cases and your project should compile fine. If you're using more advanced features such as custom schema/graphql files location,
Kotlin Gradle scripts and/or transformed queries, or if you encounter a build error after updating, read on for details about the changes.

### Gradle plugin changes

The plugin has been rewritten in Kotlin to make it more maintainable and have better support for multiple GraphQL endpoints.  Below are the
main changes. Read [plugin-configuration.md](../advanced/plugin-configuration/) for a reference of the
different options.

#### New plugin ID

The plugin ID has been changed from `com.apollographql.android` to `com.apollographql.apollo3` to make it clear that the plugin works also
for non-Android projects. `com.apollographql.android` will be removed in a future revision.

<MultiCodeBlock>

```kotlin
// Replace:
apply(plugin = "com.apollographql.android")

// With:
apply(plugin = "com.apollographql.apollo3") // highlight-line
```

```groovy
// Replace:
apply plugin: 'com.apollographql.android'

// With:
apply plugin: 'com.apollographql.apollo3' // highlight-line
```

</MultiCodeBlock>

#### Using multiple services

The plugin now requires that you specify multiple services explicitly. If you previously had the following layout:

```
src/main/graphql/com/github/schema.json
src/main/graphql/com/github/GetRepositories.graphql
src/main/graphql/com/starwars/schema.json
src/main/graphql/com/starwars/GetHeroes.graphql
```

You will need to define 2 services:

```kotlin title="build.gradle"
apollo {
  service("github") {
    sourceFolder.set("com/github")
    packageName.set("com.github")
  }
  service("starwars") {
    sourceFolder.set("com/starwars")
    packageName.set("com.starwars")
  }
}
```

#### Specifying schema and GraphQL files location

The root `schemaFilePath`, `outputPackageName` and `sourceSets.graphql` are removed and will throw an error if you try to use them. Instead
you can use [CompilationUnit] to control what files the compiler will use as inputs.

```groovy title="build.gradle"
// Replace:
sourceSets {
  main.graphql.srcDirs += "/path/to/your/graphql/queries/dir"
}

// With:
// highlight-start
apollo {
  service("service") {
    srcDir("/path/to/your/graphql/queries/dir")
  }
}
// highlight-end
```

```groovy title="build.gradle"
// Replace
apollo {
  service("service") {
    sourceSet {
      schemaFilePath = "/path/to/your/schema.json"
      exclude = "**/*.gql"
    }
    outputPackageName = "com.example"
  }
}

// With:
apollo {
  service("service") {
    schemaFile.set(file("/path/to/your/schema.json"))
    graphqlSourceDirectorySet.exclude("**/*.gql")
    packageName.set("com.example")
  }
}
```

#### Kotlin DSL

The plugin uses Gradle [Properties](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html) to support
[lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html) and wiring tasks together.

If you're using Groovy `build.gradle` build scripts it should work transparently but Kotlin `build.gradle.kts` build scripts will require
you to use the [Property.set](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html#set-T-) API:

```kotlin title="build.gradle"
apollo {
  service("service") {
    // Replace:
    setGenerateKotlinModels(true)

    // With:
    generateKotlinModels.set(true) // highlight-line
  }
}
```

Also, the classes of the plugin have been split into an [api](https://github.com/apollographql/apollo-android/tree/4692659508242d64882b8bff11efa7dcd555dbcc/apollo-gradle-plugin-incubating/src/main/kotlin/com/apollographql/apollo3/gradle/api)
part and an [internal](https://github.com/apollographql/apollo-android/tree/4692659508242d64882b8bff11efa7dcd555dbcc/apollo-gradle-plugin-incubating/src/main/kotlin/com/apollographql/apollo3/gradle/internal)
one. If you were relying on fully qualified class names from your `build.gradle.kts` files, you will have to tweak them:

```kotlin
// Replace:
import com.apollographql.apollo3.gradle.ApolloExtension

// With:
import com.apollographql.apollo3.gradle.api.ApolloExtension // highlight-line
```

### Breaking changes in generated Kotlin models with inline fragments:

Field `inlineFragment` is no longer generated with a new Apollo **1.3.0** release for Kotlin models.

For example:

[previous version of model with inline fragments](https://github.com/apollographql/apollo-android/blob/hotfix/1.2.3/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.kt#L129)

```kotlin
data class Hero(
    val __typename: String,
    /**
     * The name of the character
     */
    val name: String,
    val inlineFragment: HeroCharacter?
  ) {
    val asHuman: AsHuman? = inlineFragment as? AsHuman

    val asDroid: AsDroid? = inlineFragment as? AsDroid
...
```

[new version of generated model with inline fragments](https://github.com/apollographql/apollo-android/blob/v1.3.0/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.kt#L125)

```kotlin
  data class Hero(
    val __typename: String,
    /**
     * The name of the character
     */
    val name: String,
    val asHuman: AsHuman?,
    val asDroid: AsDroid?
  )
```

***Motivation***: there is an issue with previous version of generated model, there are cases when specified multiple inline fragments
should be resolved for the same GraphQL type. For example imagine that GraphQL schema defines this hierarchy of types
`Character <- Hero <- Human`. Having this GraphQL query:

```graphql
query {
  character {
    name
    ... on Hero { ... }
    ... on Human { ... }
   }
}
```

both inline fragments `on Hero` and `on Human` should be resolved for character type `Human` as `Hero` is super type of `Human`.

Previous version of generated model for `Character` didn't resolve both inline fragments but rather first declared `... on Hero`. New
version resolves both fragments `on Hero` and `on Human`.

***Migration***:

If you have this code to get access to the resolved inline fragment:

```kotlin
when (hero.inlineFragment) {
    is Hero.AsHuman -> // ...
    is Hero.AsDroid -> // ...
}
```

you should change it to check all declared inline fragments for nullability, as it's possible now to have multiple resolved fragments:

```kotlin
if (hero.asHuman != null) {
  // ...
}

if (hero.asDroid != null) {
  // ...
}
```

### Singularization

Singularization rules have been improved (see [1888](https://github.com/apollographql/apollo-android/pull/1888)). That means the name of
some classes that were previously wrongly or badly singularized might have changed. Check for a generated class with a similar name if that
happens.

### Nested class names

Nested classes are now allowed to have the same name as their parent (see [1893](https://github.com/apollographql/apollo-android/pull/1893)).
If you were previously using such a class, the numbered suffix will be removed.

### Transformed queries removal

Version 1.3.0 can now optionally generate a `operationOutput.json` file. This file will contain the generated queries source, operation name
and operation ID. You can use them to whitelist the operation on your server or any other use case. See
[1841](https://github.com/apollographql/apollo-android/pull/1841) for details.

Since operationOutput.json is a superset of the transformed queries, transformed queries have been removed. If you were using transformed
queries, you will now have to use operationOutput.json.

### Espresso Idling Resources

Idling Resources integration is moved to AndroidX! This is a potential breaking change for users who has not migrated to AndroidX yet. If
you haven't you can still use the 1.2.x version in your test code.

The artifact is also renamed to make its intention more obvious.

```groovy title="build.gradle"
  // Replace:
  androidTestImplementation("com.apollographql.apollo3:apollo-espresso-support:x.y.z")

  // With:
  androidTestImplementation("com.apollographql.apollo3:deprecated-apollo-idling-resource:x.y.z") // highlight-line
```
